package com.kevin.utility.common;

import java.io.File;
import java.io.FileNotFoundException;

import org.apache.log4j.Logger;
import org.springframework.util.ResourceUtils;

public class ResourceUtil { 
	private static final Logger logger = Logger.getLogger(ResourceUtil.class);
	
	public static File[] getFile(String fileName){
		try {
			File codeFile = ResourceUtils.getFile(fileName);
			if(codeFile.isDirectory()){
				File[] files = codeFile.listFiles();
				for(File file: files){
					logger.info(file.getAbsoluteFile());
					System.out.println(file.getAbsoluteFile());
				}
				return files;
			}
			
		} catch (FileNotFoundException e) {
			logger.error(e.getMessage(),e);
		}
		return null;
	}
	public static String getPath(String fileName){
		try {
			File ret = ResourceUtils.getFile(fileName);
			return ret.getAbsolutePath();
			
		} catch (FileNotFoundException e) {
			logger.error(e.getMessage(),e);
		}
		return null;
	}
}